/**
 * Copyright 2008-2009. Chongqing Communications Industry Services Co.,Ltd Information Technology Branch. All rights
 * reserved. <a>http://www.cqcis.com</a>
 */
package com.cqcis.uip.base.framework.core.impl;

import java.util.List;

import org.apache.log4j.Appender;
import org.apache.log4j.FileAppender;

import com.cqcis.uip.base.framework.core.LogRepositoryService;
import com.cqcis.uip.base.logadaptor.LogConfiguration;
import com.cqcis.uip.base.logadaptor.LoggerAppenderRepository;

/**
 * @author huangmy
 * @date   2008-2-2
 */
public class LogRepositoryServiceImpl implements LogRepositoryService {
    private LoggerAppenderRepository loggerAppenderRepository;
	
    public Appender createOrGetAppenderFor(LogConfiguration logConfig,
    		FileAppender tmplAppender) {    	
    	return loggerAppenderRepository.createOrGetAppenderFor(logConfig, tmplAppender);
    }
    
	public List<Appender> getAppenders(Thread thread) {		
		return loggerAppenderRepository.getAppenders(thread);
	}
    
	public void register(LogConfiguration logConfiguration, Thread thread) {		
		loggerAppenderRepository.register(logConfiguration, thread);
	}
	
	public void unregister(Thread thread) {
		loggerAppenderRepository.unregister(thread);
	}

	public List<LogConfiguration> getLogConfigurations(Thread thread) {		
		return this.loggerAppenderRepository.getLogConfigurations(thread);
	}
		
	public void removeLogConfiguration(LogConfiguration logConfiguration, Thread thread) {
		loggerAppenderRepository.register(logConfiguration, thread);
	}
	
	public void tryCloseLogAppender(LogConfiguration logConfiguration) {
		loggerAppenderRepository.tryCloseLogAppender(logConfiguration);
	}
	
	public void setLoggerAppenderRepository(LoggerAppenderRepository loggerAppenderRepository) {		
		this.loggerAppenderRepository = loggerAppenderRepository;
	}
}
